==[README.TXT -- Formatted for 72 Columns]==============================
  
--{1. Preface}----------------------------------------------------------
  
The Angelique Tile Editor is a product of my need for a basic hex editor
that would allow me to paste as hex into 18-byte records.  This probably
won't prove useful for anything other than 12x12 one-bit fonts.  This 
format is used by Angelique (and perhaps some other Super Famicom games)
for a special text output system.  That is, the game seems to create a 
bitplane in memory of a certain size, and paste the 12x12 tiles onto it,
thusly creating a virtual canvas that the SNES, used to sprites with 
dimensions of multiples of 8, can render.  
  
I won't guarantee that this editor will work for you, nor can I make any
guarantee that it won't harm your computer, yourself, or your property 
in some way..though the chance is pretty slim.  You use this editor at 
your own risk.  It is written in C and compiled in DJGPP, utilizing the
Allegro game programming library, though mostly only for graphics output
at the moment.  The source itself is rather sloppy, since this was a 
rush job (a few hours, over a few days), so I probably won't ever be 
releasing it to the public.  
  
--{2. Operation}--------------------------------------------------------
  
*Make sure to backup your file before you begin.*  Angetile changes the
file as you work, so there is no requirement for a 'save' function.  
To begin the program, you pass it an argument on the command line equal
to the filename of the file you wish to edit, like so; 
  
C:\ANGETILE>ANGETILE ANGELIQU.SMC
  
This, if everything goes correctly, will send the program into 320x200
VGA mode.  You can use 'ALT + Enter' to switch from fullscreen to a 
windowed DOS console in this mode..though graphics display will be a bit
slower. 
  
You'll notice that this isn't like most 'tile editors', in that rather 
than editing the image directly, it's going to ask you for a hex string.
This should change when I implement some feature sometime in the future, 
but for now, it's the only way.  Worry not, for here, I'll show you how
to create such a hex value.  (Yes, I know it's not easy for the average
person, but it's perfect for what I designed this program for.) 
  
First you make a little 12x12 'grid' of sorts, dividing it evenly into 
three columns (four 'pixels' each).  
  
---- ---- ----
---- ---- ----
---- ---- ----
---- ---- ----
---- ---- ----
---- ---- ----
---- ---- ----
---- ---- ----
---- ---- ----
---- ---- ----
---- ---- ----
---- ---- ----
  
Then you 'toggle' each pixel by replacing a '-' with a character of your
choice..though I like to use '0', since it stands out rather well versus
the field of hyphens.  
  
-000 0000 000-
00-- ---- --00
00-- ---- --00
00-- ---- --00
00-- ---- --00
0000 0000 0000
00-- ---- --00
00-- ---- --00
00-- ---- --00
00-- ---- --00
00-- ---- --00
00-- ---- --00
  
Now that we have our image, we can convert it into hexadecimal.  Since 
the image is conveniently divided into 'nibbles' (groups of four bits),
we can use the following table:  
  
---- = 0    ---0 = 1    --0- = 2    --00 = 3 
-0-- = 4    -0-0 = 5    -00- = 6    -000 = 7 
0--- = 8    0--0 = 9    0-0- = A    0-00 = B 
00-- = C    00-0 = D    000- = E    0000 = F 
  
To convert our image to hexadecimal: 
  
-000 0000 000- = 7 F E 
00-- ---- --00 = C 0 3 
00-- ---- --00 = C 0 3 
00-- ---- --00 = C 0 3 
00-- ---- --00 = C 0 3 
0000 0000 0000 = F F F 
00-- ---- --00 = C 0 3 
00-- ---- --00 = C 0 3 
00-- ---- --00 = C 0 3 
00-- ---- --00 = C 0 3 
00-- ---- --00 = C 0 3 
00-- ---- --00 = C 0 3 
  
Written out in one line, that'd be.. 
  
7FEC 03C0 3C03 C03F FFC0 3C03 C03C 03C0 3C03  
  
At any rate, use up and down (or left and right for finer tuning) to 
select the offset range you'd like to insert into, and then press 'H'. 
This will invoke the hexadecimal insertion mode.  Enter 36 hexadecimal 
digits (18 bytes worth).  Anything except 0 through 9 and A through F 
will be ignored.  If the DOS console is windowed, you can copy and paste
the hex string above right into it.  (The spaces as mentioned, will be 
ignored.) 
  
If you know the offset you want to go to, you may type 'G' to enter a 
decimal offset for where you would like to go.  Be careful; there's 
currently no check to prevent you from going past the file's actual 
range, which probably isn't what you intended to do..unless you like 
looking at a lot of meaningless bytes. 
  
When you're done making changes, just type 'Q' to quit.  
  
Angetile creates temporary files with an .SPI extension during normal 
operation.  They are only 144 bytes each, but if you are a space hound,
you can safely remove them after the program has terminated.  You could
probably write a batch file, like so: 
  
ANGETILE ANGELIQU.SMC
DEL *.SPI 
    
  
--{3. Revision History}-------------------------------------------------
  
0.1a -- First Draft 
0.3a -- Some Hex Value Display Bugs Fixed 
0.5a -- Graphical Display Fixed 
0.7a -- Hex Input Implemented (Now it's actually an 'editor'. ^.^;) 
0.9b -- More Bug Fixes 
  
--{4. To-Do}------------------------------------------------------------
  
* 'Easy' Editing Mode -- Drawing directly 'onto' the tile with a mouse.
* Allow user to specify starting offset on command line.   
  
--{5. Known Issues}-----------------------------------------------------
  
* Errata is sometimes produced when the bottom 2 or 3 lines are used in 
  an imported tile.  Solution: Manually enter it at the quoted address 
  in a more reliable hex editor, such as Hex Workshop. 
* No checks to prevent the user from jumping to out-of-range offsets.  
* Random crashes at exit?  I haven't experienced it myself for a while.
  But the bug might still be lurking. 
  
--{6. Author}-----------------------------------------------------------
  
John Fleming: noda@kymtnnet.org -- http://gv.2y.net/ 
I'm not even sure why I'm releasing it, since it's fairly optimized for
my use, and I've already gotten all the use out of it that I need to 
for where I'm going to try to make an English patch for Angelique.  But
might as well add something back to the emulation/hacking scene, right?
If something uses 12x12 1-bit tiles for fonts and such, similar to 
Angelique's, it could prove useful.    
    
--{7. Appendix}---------------------------------------------------------
  
Here's the source to a number of utilities I wrote to generate tiles in 
MUD-Forth.  While the greater majority of you probably won't know what
that is, some may still get the gist enough to make their own similar 
utilities in the language of their preference. 
  
 ==[M2H/H2M/SH2M]======================================================
 This utility reads a group of lines to produce a hex string, or vice 
 versa.  I first used them for testing my theories about how Angelique
 probably stored its font tiles.  (Which obviously turned out to be 
 true.)  I used this program to create a few special characters, but 
 the bulk of the actual character production was done by 'DTE', found 
 farther below.  Also note that this won't format correctly on a 72 
 column terminal. ^_^; 
 ======================================================================
 
 : hex2line ( s -- s' ) 
  dup "0" strcmp not if pop "----" exit then 
  dup "1" strcmp not if pop "---0" exit then 
  dup "2" strcmp not if pop "--0-" exit then 
  dup "3" strcmp not if pop "--00" exit then 
  dup "4" strcmp not if pop "-0--" exit then 
  dup "5" strcmp not if pop "-0-0" exit then 
  dup "6" strcmp not if pop "-00-" exit then 
  dup "7" strcmp not if pop "-000" exit then 
  dup "8" strcmp not if pop "0---" exit then 
  dup "9" strcmp not if pop "0--0" exit then 
  dup "A" strcmp not if pop "0-0-" exit then 
  dup "B" strcmp not if pop "0-00" exit then 
  dup "C" strcmp not if pop "00--" exit then 
  dup "D" strcmp not if pop "00-0" exit then 
  dup "E" strcmp not if pop "000-" exit then 
  dup "F" strcmp not if pop "0000" exit then 
 ; 
   
 : line2hex ( s -- s' i ) 
  dup "----" strcmp not if pop "0" 0  exit then 
  dup "---0" strcmp not if pop "1" 1  exit then 
  dup "--0-" strcmp not if pop "2" 2  exit then 
  dup "--00" strcmp not if pop "3" 3  exit then 
  dup "-0--" strcmp not if pop "4" 4  exit then 
  dup "-0-0" strcmp not if pop "5" 5  exit then 
  dup "-00-" strcmp not if pop "6" 6  exit then 
  dup "-000" strcmp not if pop "7" 7  exit then 
  dup "0---" strcmp not if pop "8" 8  exit then 
  dup "0--0" strcmp not if pop "9" 9  exit then 
  dup "0-0-" strcmp not if pop "A" 10 exit then 
  dup "0-00" strcmp not if pop "B" 11 exit then 
  dup "00--" strcmp not if pop "C" 12 exit then 
  dup "00-0" strcmp not if pop "D" 13 exit then 
  dup "000-" strcmp not if pop "E" 14 exit then 
  dup "0000" strcmp not if pop "F" 15 exit then 
 ; 
  
  lvar hexequiv 
  lvar linecount 
  lvar checksum 
  lvar totalchks 
  lvar loopcount 
  lvar widthsize 
  lvar argument 
: do_12x12 ( s -- ) 
  1 loopcount ! "" hexequiv ! 
  begin 
    loopcount @ 13 = if break then 
    1 strcut swap hex2line hexequiv @ swap strcat hexequiv ! 
    1 strcut swap hex2line hexequiv @ swap strcat hexequiv ! 
    1 strcut swap hex2line hexequiv @ swap strcat t 
    then "" hexequiv ! 
    loopcount ++ 
  repeat 
  "*DONE*" t 
 ; 
  
 : do_userdefined ( s -- ) 
  1 loopcount ! "" hexequiv ! 
  begin 
    strip dup not if break then 
    begin 
      loopcount @ widthsize @ > if 
        hexequiv @ t 
        then "" hexequiv ! 1 loopcount ! break 
      then 
      1 strcut swap hex2line hexequiv @ swap strcat hexequiv ! 
      loopcount ++ 
    repeat 
  repeat "*DONE*" t 
 ; 
  
 : do_8x8 ( s -- ) 
  1 loopcount ! "" hexequiv ! 
  begin 
    loopcount @ 9 = if break then 
    1 strcut swap hex2line hexequiv @ swap strcat hexequiv ! 
    1 strcut swap hex2line hexequiv @ swap strcat t 
    then "" hexequiv ! 
    loopcount ++ 
  repeat 
  "*DONE*" t 
 ; 
 
 : do_8x16 ( s -- ) 
  1 loopcount ! "" hexequiv ! 
  begin 
    loopcount @ 17 = if break then 
    1 strcut swap hex2line hexequiv @ swap strcat hexequiv ! 
    1 strcut swap hex2line hexequiv @ swap strcat t 
    then "" hexequiv ! 
    loopcount ++ 
  repeat 
  "*DONE*" t 
 ; 
  
 : main ( s -- ) 
  command @ tolower "m2h" strcmp not if 
    pop 
    "Begin pasting in 12x12 map.  \"0\"=ON  \"-\"=OFF" t 
    1 linecount ! 0 checksum ! "" hexequiv ! 0 totalchks ! 
    begin 
      linecount @ 13 = if break then 
      read strip dup strlen 12 = not if pop 
        "Error on Line " linecount @ intostr strcat 
        ": Illegal Format." strcat t exit 
      then 
      dup "" "-" subst "" "0" subst strip if 
        "Error on Line " linecount @ intostr strcat 
        ": Illegal Character." strcat t exit 
      then 
      4 strcut 4 strcut ( x y z ) 
      rot ( y z x ) rot ( z x y ) swap ( z y x ) 
      line2hex checksum ! 
      hexequiv @ swap strcat hexequiv ! 
      line2hex checksum @ swap + checksum ! 
      hexequiv @ swap strcat hexequiv ! 
      line2hex checksum @ swap + checksum ! 
      hexequiv @ swap strcat hexequiv ! 
      linecount @ intostr 
      dup strlen 1 = if "0" swap strcat then 
      ": OK -- Checksum (" strcat 
      checksum @ intostr strcat ")" strcat t 
      totalchks @ checksum @ + totalchks ! 
      0 checksum ! 
      linecount ++ 
    repeat 
    hexequiv @ 
    32 strcut swap " " strcat swap strcat 
    28 strcut swap " " strcat swap strcat 
    24 strcut swap " " strcat swap strcat  
    20 strcut swap " " strcat swap strcat 
    16 strcut swap " " strcat swap strcat 
    12 strcut swap " " strcat swap strcat 
     8 strcut swap " " strcat swap strcat 
     4 strcut swap " " strcat swap strcat 
    hexequiv ! 
    "*DONE*" t 
    "Hex: " hexequiv @ strcat t 
    "Checksum: " totalchks @ intostr strcat " / 4608" strcat t 
  else 
    strip toupper "" " " subst dup strlen 
    command @ tolower "sh2m" strcmp not if 
      pop argument ! 
      begin 
        "Stream width in nibbles(4-bits):" t read atoi 
        dup 1 < if pop "Number out of range." t continue else break then 
      repeat widthsize ! 
      argument @ do_userdefined exit 
    else 
      dup 36 = if pop "OK: 12x12 Tile Image Detected." t do_12x12 exit then 
      dup 16 = if pop "OK: 8x8 Tile Image Detected." t do_8x8 exit then 
      dup 32 = if pop "OK: 8x16 Tile Image Detected." t do_8x16 exit then 
    then 
    pop "I don't recognize that Tile Image format.  (Supports 12x12, 8x8, and 8x16.)" t exit 
  then 
 ; 
  
 ==[DTE]===============================================================
 This program combines two 6x12 tiles into one 12x12 tile, thus forming
 a DTE tile rather easily for a named combination.  Note that the 
 output here is in an Angetile friendly format, for easy pasting.  'P'
 is something I wrote especially for this kind of 'scripting'.  It's a
 paste-friendly alias for increasing the offset by 18 bytes, thus you 
 could string a bunch of these together at once.  (I wrote a utility 
 for that, too..but that's another story.) 
 ======================================================================
 
 : line2hex ( s -- s' ) 
  dup "----" strcmp not if pop "0" exit then 
  dup "---0" strcmp not if pop "1" exit then 
  dup "--0-" strcmp not if pop "2" exit then 
  dup "--00" strcmp not if pop "3" exit then 
  dup "-0--" strcmp not if pop "4" exit then 
  dup "-0-0" strcmp not if pop "5" exit then 
  dup "-00-" strcmp not if pop "6" exit then 
  dup "-000" strcmp not if pop "7" exit then 
  dup "0---" strcmp not if pop "8" exit then 
  dup "0--0" strcmp not if pop "9" exit then 
  dup "0-0-" strcmp not if pop "A" exit then 
  dup "0-00" strcmp not if pop "B" exit then 
  dup "00--" strcmp not if pop "C" exit then 
  dup "00-0" strcmp not if pop "D" exit then 
  dup "000-" strcmp not if pop "E" exit then 
  dup "0000" strcmp not if pop "F" exit then 
 ; 
  
   lvar curline 
   lvar arg1 
   lvar arg2 
   lvar output 
 : main ( s -- ) 
  strip "" " " subst dup strlen 2 = not if 
    "Syntax: dte $$ -- Where $'s are each a supported font character." t 
    exit 
  then 1 strcut arg2 ! arg1 ! 
  prog "_font/" arg1 @ strcat "/1" strcat getpropstr strip not if 
    "Invalid First Character: " arg1 @ strcat t exit 
  then 
  prog "_font/" arg2 @ strcat "/2" strcat getpropstr strip not if 
    "Invalid Second Character: " arg2 @ strcat t exit 
  then 
  "" output ! 1 curline ! begin 
    curline @ 13 = if break then 
    prog "_font/" arg1 @ strcat "/" strcat curline @ intostr strcat getpropstr 
    strip dup strlen 6 = not if pop 
      "First Character (" arg1 @ strcat ") Error on Bit Line " strcat 
      curline @ intostr strcat t exit 
    then 
    prog "_font/" arg2 @ strcat "/" strcat curline @ intostr strcat getpropstr 
    strip dup strlen 6 = not if pop 
      "First Character (" arg2 @ strcat ") Error on Bit Line " strcat 
      curline @ intostr strcat t exit 
    then strcat 
    dup "" "-" subst "" "0" subst strip if 
      "Error Generating Line " curline @ intostr strcat "." strcat t exit 
    then 
    4 strcut 4 strcut ( x y z ) 
    rot ( y z x ) rot ( z x y ) swap ( z y x ) 
    line2hex output @ swap strcat output ! 
    line2hex output @ swap strcat output ! 
    line2hex output @ swap strcat output ! 
    curline ++ 
  repeat 
  "" output @ 
  me @ "_prefs/wordgrouped?" getprop if 
    32 strcut swap " " strcat swap strcat 
    28 strcut swap " " strcat swap strcat 
    24 strcut swap " " strcat swap strcat  
    20 strcut swap " " strcat swap strcat 
    16 strcut swap " " strcat swap strcat 
    12 strcut swap " " strcat swap strcat 
     8 strcut swap " " strcat swap strcat 
     4 strcut swap " " strcat swap strcat 
  then 
  "H " swap strcat 
  " P" strcat 
  strcat t 
 ; 
 
==[EMD]=================================================================
